package it.polito.connectedcar;

import it.polito.connectedcar.network.EntityNetworkConnector;
import it.polito.connectedcar.network.EntityNetworkConnectorFactory;
import it.polito.connectedcar.network.NetworkConnectorFactory;

import java.net.InetAddress;

public abstract class BaseConnectedObject {

	protected EntityNetworkConnector networkConnector;
	protected InetAddress TCCAddress;
	protected Integer TCCPort;
	
	public BaseConnectedObject() throws Exception {
		
		NetworkConnectorFactory factory = EntityNetworkConnectorFactory.newFactoryInstance();
		networkConnector = factory.getConnector();
		try
		{
			String address = System.getProperty("TCC-address");
			TCCAddress = InetAddress.getByName(address);
			TCCPort = Integer.parseInt(System.getProperty("TCC-port"));
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception(e.getMessage());
		}
	}
}
